<template>
	<view class="content">
		<view>
			<!-- <span >试题内容:</span> -->
			<!-- <rich-text class="miningpoint" :nodes="item.questionsname"></rich-text> -->
		</view>
		<view>
			<span class="title">【我的答案】</span>
			<rich-text :nodes="item.myanswer"></rich-text>
		</view>
		<block v-if="item.source == '1'">
			<view>
				<span class="title">【评语】</span>
				<rich-text :nodes="item.comment"></rich-text>
			</view>
			<view>
				<span class="title">【得分】</span>
				<view class="score">{{ item.score }}</view>
			</view>
			<view>

				<span class="title">【批改人】</span>
				<view class="comrname">{{ item.comrname }}</view>
			</view>
		</block>
		<block v-if="item.source == '2' || item.source == '3'">
			<view>
				<span class="title">【评语】</span>
				<view>
					<rich-text :nodes="item.correctcomment"></rich-text>
				</view>
				<view class="imt-audio" v-if="item.correctorvo!=''">
					<view class="audio-control-wrapper">
						<view class="audio-control audio-control-switch" :class="{audioLoading:loading}" @click="operation">
							<image v-if="paused" src="/static/img/audio/play.png" class="audio-img" mode=""></image>
							<image v-if="!paused" src="/static/img/audio/pause.png" class="audio-img" mode=""></image>
							<!-- {{loading?'&#xe600;':(paused?'&#xe865;':'&#xe612;')}} -->
						</view>
					</view>
				</view>
			</view>
			<view>
				<span class="title">【得分】</span>
				<view class="score">{{ item.correctscore }}</view>
			</view>
			<view>
				<span class="title">【批改人】</span>
				<view class="comrname">{{ item.corrector }}</view>
			</view>
			<view>
				<span class="title">【批改时间】</span>
				<view class="comrname">{{ item.correcttime }}</view>
			</view>
		</block>
	</view>
</template>

<script>
	import discussMarkApi from "@/api/subjectiveCase.js"

	const audio = uni.createInnerAudioContext(); //创建音频

	let _this;
	export default {
		components: {},
		data() {
			return {
				query: {},
				item: {},
				loading: false, //是否处于读取状态
				paused: true, //是否处于暂停状态
				seek: false //是否处于拖动状态
			};
		},

		onLoad(query) {
			_this = this;
			_this.query = query
			_this.initData()
		},
		onBackPress() {
			console.log('back')
			audio.stop()
		},
		methods: {
			initData(source) {
				discussMarkApi.brst_info({
					dt_id: _this.query.id
				}).then(res => {
					_this.item = res.data
					_this.initAudio()
				})
			},
			//播放/暂停操作
			operation() {
				if (_this.paused) {
					audio.play()
					this.loading = true
				} else {
					audio.pause()
				}
			},
			initAudio() {
				audio.src = _this.item.correctorvo
				audio.obeyMuteSwitch = false
				audio.autoplay = false
				//音频播放事件
				audio.onPlay(() => {
					_this.paused = false
					_this.loading = false
				})
				//音频暂停事件
				audio.onPause(() => {
					_this.paused = true
				})
				//音频结束事件
				audio.onEnded(() => {
					if (_this.continue) {
						_this.next()
					} else {
						_this.paused = true
						_this.current = 0
					}
				})
				//音频完成更改进度事件
				audio.onSeeked(() => {
					_this.seek = false
				})
				// audio.stop()
			}


		},
	}
</script>

<style lang="scss">
	page,
	.content {
		display: flex;
		justify-content: flex-start;
		align-items: center;
		width: 100%;
		padding: 0 10upx;

		font-size: $font-sm+5;
		color: $font-color-dark;
		word-wrap: break-all;
		flex-wrap: wrap;
		font-weight: 600;

		>view {
			width: 100%;
			word-wrap: break-word;
			font-weight: 500;
			padding-top: 10upx;
		}
		
		.title {
			color: #4f81bd;
		}

		.score {
			font-size: $font-sm + 2upx;
			color: $uni-color-primary;
			word-wrap: normal;
			overflow: hidden;
			line-height: 60upx;
			text-indent:1em;
		}

		.comrname {
			word-wrap: normal;
			overflow: hidden;
			line-height: 60upx;
			text-indent:1em;
		}

	}

	.imt-audio {
		width: 200upx;
		padding: 0upx;
		background: #fff;
		border-radius: 20upx;
	}

	.audio-control-wrapper {
		margin-top: 10upx;
		display: flex;
		justify-content: center;
		align-items: center;
		// color:#169af3;
	}

	.audio-control {
		font-size: 32upx;
		line-height: 1;
		// border: 4upx solid;
		// border-radius: 50%;
		padding: 16upx;

		.audio-img {
			width: 100upx;
			height: 100upx;
		}
	}
	rich-text{
		line-height: 60upx;
		text-indent:2em;
	}
</style>